package cn.bocweb.spinning.view.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CheckBox;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;

import java.util.List;

import butterknife.Bind;
import butterknife.ButterKnife;
import cn.bocweb.spinning.R;
import cn.bocweb.spinning.model.Bean.CollectCompanyBean;
import cn.bocweb.spinning.view.common.MyAdapter;

/**
 * Created by chenchangxing on 16/3/28.
 */
public class CollectCompanyAdapter extends MyAdapter<CollectCompanyBean.DataBean> {

    public CollectCompanyAdapter(Context context, List<CollectCompanyBean.DataBean> list) {
        super(context, list);
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder;

        if (convertView == null) {
            convertView = inflater.inflate(R.layout.item_collect_info, parent, false);
            holder = new ViewHolder(convertView);
            convertView.setTag(holder);
        } else {
            holder = (ViewHolder)convertView.getTag();
        }

        Glide.with(context)
                .load(list.get(position).getPhoto())
                .error(R.mipmap.banner_empty)
                .into(holder.collectInfoIcon);

        holder.collectInfoTitle.setText(list.get(position).getIntro_name());
        holder.collectInfoContent.setText(list.get(position).getIntro_brief());

        return convertView;
    }

    static class ViewHolder {
        @Bind(R.id.collect_info_select)
        CheckBox collectInfoSelect;
        @Bind(R.id.collect_info_icon)
        ImageView collectInfoIcon;
        @Bind(R.id.collect_info_title)
        TextView collectInfoTitle;
        @Bind(R.id.collect_info_content)
        TextView collectInfoContent;

        ViewHolder(View view) {
            ButterKnife.bind(this, view);
        }
    }
}
